package com.fly;

import java.io.IOException;
import java.util.stream.Stream;

import org.apache.commons.lang3.SystemUtils;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.fly.common.utils.SpringContextUtils;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * SpringBootApplication 启动类
 * 
 * @author 00fly
 * @version [版本号, 2018-09-11]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Slf4j
@EnableScheduling
@SpringBootApplication
public class DbutilsApplication implements CommandLineRunner
{
    public static void main(String[] args)
    {
        // 加载外部配置文件
        // args = new String[] {"--spring.config.location=.\application-location.yml"};
        Stream.of(args).forEach(log::info);
        SpringApplication.run(DbutilsApplication.class, args);
    }
    
    @Override
    public void run(String... args)
        throws IOException
    {
        if (SystemUtils.IS_OS_WINDOWS)
        {
            log.info("★★★★★★★★  now open Browser ★★★★★★★★ ");
            String url = SpringContextUtils.getServerBaseURL();
            Runtime.getRuntime().exec("cmd /c start /min " + url + "/user/list");
            Runtime.getRuntime().exec("cmd /c start /min " + url + "/druid");
            Runtime.getRuntime().exec("cmd /c start /min " + url + "/doc.html");
        }
    }
}
